package com.czh.controller;

import com.czh.domain.ResponseResult;
import com.czh.domain.dto.AddArticleDto;
import com.czh.service.ArticleService;
import com.czh.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
写博客控制器
 */
@RestController
public class WriteBlogController {
    @Autowired
    private UploadService uploadService;
    @Autowired
    private ArticleService articleService;
    // 上传图片
    @PostMapping("/upload")
    public ResponseResult<String> upload(@RequestParam("img")MultipartFile img) {
        return uploadService.uploadImg(img);
    }
    @PostMapping("/content/article")
    public ResponseResult<Object> addArticle(@RequestBody AddArticleDto addArticleDto) {
        return articleService.addArticle(addArticleDto);
    }
}
